package com.aoyy.dao;

import java.util.List;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.aoyy.model.Order;
import com.aoyy.model.User;
/**==========================================================================
 * <code>OrderDaoImpl</code> class for <code>Order</code> DAO
 * @author Administrator
 * @date 2017-07-13
 * ========================================================================== */
@Repository("orderDao")
@Transactional
public class OrderDaoImpl extends BaseDaoImpl<Order> implements IOrderDao {
  @Override
  @Transactional(propagation=Propagation.NOT_SUPPORTED, readOnly=true)  
  public Order getOrderByUser(User user) {
	if (user != null && user.getUserId() != null) {
	  String where = "from Order where user.userId = ?";
	  Object[] parameters = {user.getUserId()};
	  List<Order> list = this.query(where, parameters, -1, -1).getList();
	  if (list != null && list.size() > 0) {
		return list.get(0);  
	  }
	}
	return null;
  }

}
